home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / gengui2.lha / GenGui2 / Examples / palette.c < prev    next >
C/C++ Source or Header  |  1995-02-15  |  3KB  |  100 lines

  1.  
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <proto/intuition.h>
  5. #include <intuition/intuition.h>
  6. #include <proto/exec.h>
  7. #include <proto/graphics.h>
  8. #include <proto/layers.h>
  9. #include <libraries/gadtools.h>
  10.  
  11. #include "palette.h"
  12.  
  13. #include <graphics/gfxmacros.h>
  14.  
  15. extern struct IntuitionBase *IntuitionBase;
  16. extern struct GfxBase *GfxBase;
  17. extern struct Library *GadToolsBase;
  18.  
  19.  
  20. main()
  21. {
  22.    struct IntuiMessage *msg;
  23.    struct Window *win;
  24.    int run=1;
  25.    struct TextFont *font=NULL;
  26.  
  27.    struct Hook hook;
  28.    int depth;
  29.  
  30.    hook.h_Entry=(HOOKFUNC)HookFunc;
  31.    hook.h_SubEntry=NULL;
  32.    hook.h_Data=COLOR(2,0);
  33.  
  34.    win=OpenWindowTags(NULL,
  35.             WA_Left,0,WA_Top,20,
  36.             WA_Width,300,WA_Height,100,
  37.             WA_Title,"Palette",
  38.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  39.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW|
  40.                      IDCMP_SIZEVERIFY,
  41.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  42.                         |WFLG_SIMPLE_REFRESH
  43.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  44.             WA_MinWidth,300,WA_MinHeight,100,
  45.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  46.             WA_BackFill,&hook,
  47.             TAG_DONE );
  48.  
  49.    if(!win) exit(0);
  50.  
  51.    depth=win->RPort->BitMap->Depth;
  52.  
  53.    GG_SetLowlevelAttrs(&TestPro_GadInfo_PALETTE,GTPA_Depth,depth,TAG_DONE);
  54.  
  55.    if(GG_SmartRenderGui(win,&TestPro,&font)) {CloseWindow(win);if(font) CloseFont(font);exit(0);}
  56.  
  57.    PaletteHook(NULL); /* Initialize palette */
  58.  
  59.    while(run) {
  60.       WaitPort(win->UserPort);
  61.       while(msg=GG_GetIMsg(win->UserPort)) {
  62.          switch(msg->Class) {
  63.             case IDCMP_CLOSEWINDOW: run=0;
  64.                                     break;
  65.             case IDCMP_NEWSIZE:     GG_ResizeGui(&TestPro);
  66.                                     break;
  67.             case IDCMP_REFRESHWINDOW:
  68.                                     GG_RefreshGui(&TestPro);
  69.                                     break;
  70.             case IDCMP_SIZEVERIFY:  GG_BeginResizeGui(&TestPro);
  71.                                     break;
  72.             case IDCMP_GADGETUP:
  73.                      switch(GetGadget(msg)->GadgetID) {
  74.  
  75.                         case PLUS:  if(depth<win->RPort->BitMap->Depth) {
  76.                                        depth++;
  77.  
  78.                                        GG_SetLowlevelAttrs(&TestPro_GadInfo_PALETTE,GTPA_Depth,depth,TAG_DONE);
  79.                                        GG_ResizeGui(&TestPro);
  80.                                     }
  81.                                     break;
  82.                         case MINUS: if(depth>1) {
  83.                                        depth--;
  84.  
  85.                                        GG_SetLowlevelAttrs(&TestPro_GadInfo_PALETTE,GTPA_Depth,depth,TAG_DONE);
  86.                                        GG_ResizeGui(&TestPro);
  87.                                     }
  88.                                     break;
  89.                      }
  90.                      break;
  91.          }
  92.          GG_ReplyIMsg(msg);
  93.       }
  94.    }
  95.    GG_FreeGui(&TestPro);
  96.    CloseWindow(win);
  97.    if(font) CloseFont(font);
  98.    return(0);
  99. }
  100.